package tfsIssueTracker.commands;

import com.intellij.execution.configurations.GeneralCommandLine;
import jetbrains.buildServer.issueTracker.IssueData;
import tfsIssueTracker.Settings;

public class GetIssueByIdCommand extends TfsCommand<IssueData> {
    private final String id;

    public GetIssueByIdCommand(String id, Settings settings) {
        super(settings);
        this.id = id;
    }

    @Override
    protected String getCommandName() {
        return "GetById";
    }

    @Override
    protected void addCommandSpecificArguments(GeneralCommandLine cli) {
        cli.addParameter(id);
    }

    @Override
    protected IssueData parseResult(String stdout) {
        String[] lines = stdout.split("\n");

        return new IssueData(lines[0], lines[1], lines[2], lines[3], Boolean.getBoolean(lines[4]));
    }
}
